package com.shoulei.designpattern.builderPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName:Meal
 * @Descrition:
 * @Author:shoulei
 * @Date:2019/3/31 20:30
 * @Verson:
 */
public class Meal {
    List<Item> items = new ArrayList<Item>();
    public void add(Item item){
        items.add(item);
    }

    public float getCost(){
        float cost = 0.0f;
        for(Item item:items){
            cost += item.price();
        }
        return cost;
    }

    public void showItems(){
        for(Item item:items){
            System.out.println("Item:"+item.name());
            System.out.println(", packing:" + item.packing().pack());
            System.out.println(", price:" + item.price());
        }
    }
}
